function PrescheduleUploader() {
    var the = this;
    var allowFileExt = ["xls", "xlsx"];

    var fileList = $("#uploadMsg");

    this.createUploader = function (taskId) {
        var postData = {
            "taskId": taskId
        };
        var uploader = WebUploader.create({
            auto: true,
            swf: '/static/webuploader/Uploader.swf',
            server: "/m/preschedule/upload",
            formData: postData,
            pick: '#uploderPicker',
            resize: false
        });

        // 上传前校验格式
        uploader.on('beforeFileQueued', function (file) {
            var fileExt = file.ext.toLowerCase();
            if (allowFileExt.contains(fileExt)) {
                fileList.empty();
                return true;
            }else {
                alert("上传的文件格式不正确！");
                return false;
            }
        });

        // 当有文件添加进来的时候
        uploader.on('fileQueued', function (file) {
            showUploadStatus("上传中...");
            setUploderPickerDisable(true);
        });

        // 上传成功
        uploader.on('uploadSuccess', function (file, response) {
            var ret = response;
            if (ret == 1) {
                showUploadStatus("上传成功");
                location.reload();
            } else {
                showUploadStatus("上传失败");
            }

            setUploderPickerDisable(false);

            the.createUploader(taskId);
        });

        // 上传失败
        uploader.on('uploadError', function (file) {
            showUploadStatus("上传失败");
            the.createUploader(taskId);
        });

        function showUploadStatus(msg) {
            fileList.html(msg);
        }

        function setUploderPickerDisable(disabled) {
            var $uploderPicker = $("#uploderPicker");
            if(disabled){
                $uploderPicker.attr("disabled","disabled");
            }else {
                $uploderPicker.removeAttr("disabled");
            }
        }
    }
}